﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Billing.DataObjects
{
    public partial class ClientsView : Billing.IBaseObject
    {
        public object Value
        {
            get
            {
                return this.ID;
            }
            set
            {

            }
        }

        public object CurrentObject
        {
            get { return this; }
        }

        partial void OnClientStatusIDChanged()
        {
            ClientStatus = BillingDataContext.Context.GetClientStatusByID(ClientStatusID).Name;
        }

        partial void OnClientTypeIDChanged()
        {
            ClientType = BillingDataContext.Context.GetClientTypeByID(ClientTypeID).Name;
        }

        partial void OnTaxIDChanged()
        {
            Tax = BillingDataContext.Context.GetTaxByID(TaxID).Name;
        }

        partial void OnCreated()
        {
            PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(OnPropertyChanged);
        }

        void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            if (!e.PropertyName.Equals("ModifiedDate"))
            {
                ModifiedDate = DateTime.Now;
            }
        }

        public bool ExistsInDB
        {
            get
            {
                return BillingDataContext.Context.GetClientViewByID(ID) != null;
            }
        }
    }
}
